<?php
/**
 * Created by PhpStorm.
 * User: hulinhua
 * Date: 2018/1/30
 * Time: 下午2:39
 */

namespace app\index\controller;
use app\index\model\UserModel;
use function Sodium\add;
use think\controller;

class HomeController extends controller
{
    public function index()
    {

        $userInfo = session('userInfo');

        if ($userInfo) {

            $userModel = new UserModel();
            $userModel->bindUserInfo($userInfo);
            $ddd = [
                'avatar'=>$userModel->getUser_avatar(),
                'nickname'=>$userModel->getUser_nickname(),
            ];

            return $this->fetch('home',$ddd);


        }else{
            return $this->fetch('login_controller/login');
        }

    }

    public function loginOut()
    {

        session('userInfo',null);
        return $this->redirect('/login');
    }
}